package com.seven.annotation;

import com.seven.commons.AbstractSevenException;
import com.seven.commons.AnnotationException;

import java.lang.annotation.Annotation;

/**
 * @projectname:common-utils
 * @author: sevenDay
 * @date: 2019/7/15 15:47
 * @desc:
 */
public abstract class BaseComponent {

    /**
     * //throw new AnnotationException(BaseResultEnum.UNKNOWN_ERROR.getCode(), BaseResultEnum.UNKNOWN_ERROR.getMsg());
     * @param e
     * @throws Throwable
     */
    public void throwException(Throwable e) throws Throwable {
        if (e instanceof AbstractSevenException){
            AbstractSevenException a = (AbstractSevenException)e;
            throw new AnnotationException(a.getCode(), a.getMsg());
        }else{
            throw e;
        }
    }
}
